<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>
        PhpServlet
    </title>
<style>
@media screen {
body {font-family: "Times New Roman", Times, serif;	font-size:11pt;	text-decoration: none;	
	line-height:14pt;}
h1 {font-size:16pt;text-decoration:underline;font-weight:bold;}
h2 {font-family: sans-serif;font-size: 12pt;font-style:italic;}
a:link, a:visited {	color:#996699;	text-decoration:none;}
a:hover, a:active {	color:#996699;	text-decoration: underline;}
.small {font-size:9pt;}	

#pic{position:absolute;top:10;left:10;width:233;}
#menu {position:absolute;top:250;left:5;text-align:right;width:220;line-height:12pt;}
#text {position:absolute;top:20;left:260;height:402;width:400;overflow:auto;padding:4;
		text-decoration:none;}
}

@media print {
#text {font-size:11pt;}
#menu{position:absolute;top:20;left:300;text-align:right;}
a {color:black;text-decoration:none}
}
</style>
</head>
   <body onload="setTimeout('location.reload()',200)">
   	<div id="pic">
		<img src="phpservlet.jpg" width="233" height="228" 
		border="0" alt="PhpServlet Logo" usemap="#phpservlet_map">
   	</div>
	<map name="phpservlet_map">
		<area title="php.net" alt="php.net" shape="circle" coords="98,38,35" href="http://www.php.net" target="_blank">
		<area title="Learn jsp and servlets at akademie.de (german)" 
		alt="Learn jsp and servlets at akademie.de (german)" coords="4,74,224,166" 
		href="http://www.akademie.de/websiteaufbau/workshops/jsp-java-server-pages-workshop/index.html" 
		target="_blank">
		<area title="herberlin.de" alt="herberlin.de" coords="100,170,224,202" href="http://www.herberlin.de" target="_top">
	</map>

	
   	<div id="menu">
		<a href="#introduction">Introduction</a><br>
		<a href="#licence">Licence</a><br>
		<a href="#running">Running</a><br>
		<a href="#limitations">Limitations</a><br>
		<a href="#tests">Tests</a><br>
		<a href="#feedback">Feedback</a><br>
		<br>
		<br><br>
		
		<span class="small">Last update 2004-01-09<br>
		Copyright &copy; 2004 Hans Joachim Herbertz</span>
   	</div>
	
	
	<div id="text">

    <a name="phpservlet"></a>
	<h1>PhpServlet</h1>
	
      <a name="introduction"></a>
	  <h2>Introduction</h2>
		If you are developing <a href="http://java.sun.com/products/jsp/" target="_blank">JSPs</a> 
		and <a href="http://java.sun.com/products/servlet/" target="_blank">servlets</a> 
		you might sometimes find some
		old php scripts and projects that you probably would like to run
		on your server. But the servlet engine does not work with <a href="http://www.php.net" 
		target="_blank">php</a>, so you
		have to download and install 
		<a href="http://httpd.apache.org/" target="_blank">Apache</a>, 
		configure php, configure the
		servlet engine connector or worse use different ports and so on. It
		would be nice to get php running on 
		<a href="http://jakarta.apache.org/tomcat" target="_blank">Tomcat</a> 
		or any other servlet engine, just for development purposes.<br>
		<br>
		As you probably know a servlet comes with php that should solve this
		problem. But it does not. With the current php version (4.3.2), and
		maybe other versions too, this servlet does not work. While lots of
		environment variables - the whole windows environment stuff - are given
		to php, the HTTP_ variables are completely missing. Even worse, a "404
		Not Found" header from php crashes Tomcat (4.1.19). If you want to try
		this servlet, an introduction can be found here.<br>
		<br>
		The Herberlin php servlet is a pure <a href="http://java.sun.com" target="_blank">Java</a> 
		implementation that does not use native libraries. It's easy to install 
		and configure (like any
		other servlet). It calls the php interpreter as a process according to
		the specifications of the <a href="http://www.w3.org/CGI/" target="_blank">Common 
		Gateway Interface</a> (CGI) Version 1.1.
		This is a well-documented open standard that is also supported by the
		<a href="http://httpd.apache.org/docs/mod/module-dict.html" target="_blank">Apache</a> 
		web server, although in a production environment the use of the
		php machine as Apache module is recommended. Anyway, for a development
		environment, the cgi mode is fast enough.&nbsp;&nbsp;<br>
		
        <a name="licence"></a>
		
		<h2>Licence</h2>
		Herberlin phpservlet and the bundled herberlin wwwutil - library
		are delivered under the terms of the <a href="http://www.gnu.org" target="_blank">GNU</a> 
		LESSER GENERAL PUBLIC LICENSE and copyrighted by Hans Joachim Herbertz
		<a href="http://www.herberlin.de">http://www.herberlin.de</a>. 
		You should find the licence text with the distribution.<br>
		
		<a name="running"></a>
		
		<h2>Running</h2>
		Software and documentation are packed as a web application war-file.
		Download the current release<br>
		<ul type="disc">
			<li><a href="phpservlet.war">phpservlet.war</a>
			<li><a href="phpservlet.war.MD5">md 5</a>
		</ul>
		and drop it into the webapp-directory of your servlet engine. Call
		http://localhost/phpservlet and see this page on your local
		environment.<br>
		<br>
		The servlet engine will unpack the war-file into a directory named phpservlet.
		Find the file <strong>WEB-INF/web.xml</strong> and set the path to your php-executable 
		as described there. A sample web.xml can be found <a href="web.xml.txt" target="_blank">here</a>.<br>
		<br>
		
		<div style="background-color:#EEEEEE;">
		<strong>The following links only work on your local server:</strong><br>
		If you want to compile the PhpServlet you'll need the <a href="src.zip">sources</a> and
		the WEB-INF/lib/herberlin_wwwutil.jar library that 
		also comes with sources included in the jar-file. For a simple deployment onto your server I packed the 
		PhpServlet and the library together into one jar <a href="phpservlet.jar">phpservlet.jar</a>.
		For servlet configuration see WEB-INF/web.xml.
		</div>
				
		<a name="limitations"></a>
		<h2>Limitations / Features</h2>
		The phpservlet requires a Java runtime version 1.4. The multipart-form-data encoding (file
		upload) is now supported. Configurable cgi - environment via web.xml.
		Known bugs and version history can be found <a target="_blank" href="bugs.html">here</a>.<br>
		
		<a name="tests"></a>
		<h2>Tests</h2>
		<div style="background-color:#EEEEEE;">
		<strong>The following links only work on your local server:</strong><br>
		Find the following php-files for your tests:
		<ul>
			<li><a href="phpinfo.php" target="_blank">phpinfo.php</a> displays the phpinfo.
			<li><a href="globals.php" target="_blank">globals.php</a> shows php environment and server variables.
				You may also do some requests with querystring and post variables.
			<li><a href="redirect.php" target="_blank">redirect.php</a> sends a Location redirect header.
			<li><a href="include.php" target="_blank">include.php</a> includes the deployment descriptor
				to test the include.
			<li><a href="upload.php" target="_blank">upload.php</a> tests the multipart-formdata (file upload).
				You must enable php.use.multipart.formdata in the web.xml before running this test.
			<li><a href="error.php" target="_blank">error.php</a> leads to a php error for an include file
				is not present.
		</ul>
		</div>
		Among the sources some unit tests for development purpose
		can be found. To run the tests you will need the <a href="http://www.junit.org" target="_blank">JUnit</a> 
		and <a href="http://www.httpunit.org" target="_blank">HttpUnit</a>
		frameworks.<br>
		
		<a name="feedback"></a>
		<h2>Feedback</h2>
		The phpservlet is not yet well tested. As mentioned above I'm running
		it on Windows XP and Tomcat 4.1.29 with php 4.3.2, Win2000, <a 
		href="http://www.caucho.com" target="_blank">Caucho</a>
		Resin 2.1.4 and php 4.2.2 and Tomcat 5.0.16 with php 4.1.0 on Suse Linux 8.
		Both pass the tests and seem to work. If you
		find any bugs with these or other configurations please report to
		<em>phpservletATherberlin.de</em>.<br><br>Thanks and have fun.<br>
		<br>Hans Joachim Herbertz<br><br>
		
		<div class="small" align="right"><a href="#phpservlet">Top</a></div>
		
   	</div>
   </body>
</html>
